package com.briup.homework.chap10;

public class Test4_interrupt {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(i);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        t1.start();
        // 在main线程中打断线程t1
        t1.interrupt();
        System.out.println("main线程执行完毕");

    }
}
